<template>
  <div>
    <el-dialog title="维修单详情" :close-on-click-modal="false" :visible.sync="visible" center>
      <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
      <el-form :model="dataForm" ref="dataForm" label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="顾客姓名" prop="customerName">
              <el-input v-model="dataForm.customerName" readonly></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="customerTel">
              <el-input v-model="dataForm.customerTel" readonly></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="维修项目" prop="repairConfigId">
              <el-select v-model="dataForm.repairConfigId" placeholder="请选择" disabled>
                  <el-option
                    v-for="item in repairConfig"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-col :span="12">
              <el-form-item label="维修部门" prop="workDeptId">
                <el-select v-model="dataForm.workDeptId" placeholder="请选择" disabled>
                  <el-option v-for="item in deptOptions" :key="item.value" :label="item.name" :value="item.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-col>
        </el-row>
        <el-form-item label="维修信息" prop="repairInfo">
          <el-input v-model="dataForm.repairInfo" type="textarea" readonly></el-input>
        </el-form-item>
      </el-form>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button v-if="dataForm.repairStatus == '1'" type="primary" @click="repairFormCheck" :loading="ischeck" v-prevent-re-click>维 修</el-button>
      </span> -->
    </el-dialog>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'
  import { remote } from '@/api/admin/dict'
  import { checkRepair, repairMaching } from '@/api/eims/repair'

  export default {
    data() {
      return {
        visible: false,
        ischeck: false,
        dataForm: {
          id: 0,
          customerName: '',
          customerTel: '',
          repairConfigId: '',
          workDeptId: '',
          repairInfo: ''
        },
      }
    },
    computed: {
      ...mapGetters(['bizData'])
    },
    methods: {
      init(id,repairConfig) {
        this.repairConfig = repairConfig
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            checkRepair(this.dataForm.id).then(response => {
							if(response.data.code == 0){
								this.dataForm = response.data.data
							}else{
								this.$message.error(response.data.msg)
							}
            })
          }
        })
      },
      // 订单维修
      repairFormCheck() {
        this.ischeck = true
        repairMaching(this.dataForm.id).then(response => {
          if(response.data.code == '0'){
            this.$message.success('订单维修完成')
            this.visible = false
            this.$emit('refreshDataList')
            setTimeout(() => {
              this.ischeck = false
            })
          }else{
            this.$message.error(response.data.msg)
          }
        }).catch((error) => {
          this.ischeck = false
          this.$message.error(error)
        })
      }
    }
  }
</script>
